<%@ page import="com.fduss.artStore.entity.Artist" %>
<%@ page import="com.fduss.artStore.entity.Artwork" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: duocai wu
  Date: 2017/7/1
  Time: 17:27
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <%--<link rel="icon" href="../../favicon.ico">--%>

    <title>Artists</title>

    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

</head>
<body>
    <jsp:useBean id="artistService" scope="session" class="com.fduss.artStore.service.impl.ArtistServiceImpl"/>
    <jsp:useBean id="artworkService" scope="session"
                 class="com.fduss.artStore.service.impl.ArtworkServiceImpl"/>
    <%
        String artworkBase = "./art-images/works/small/";
        String artistBase = "./art-images/artists/small/";
        String suffix = ".jpg";
        List<Artist> artists = artistService.getAll();
        int count = artists.size();
        int rowSize = 3;
        int rowNum = (count + 1) / rowSize;
    %>
    <%@include file="header.jsp" %>
    <div class="container" style="margin-top: 50px;">
        <div class="page-header">
            <h1>Artists</h1>
        </div>
        <% for (int k = 0; k < rowNum; k++) { %>
        <!-- Three columns of text below the carousel -->
        <div class="row">
            <% for (int i = 0; k * rowSize + i < count; i++) {
                Artist artist = artists.get(k * rowSize + i);
                List<Artwork> artworks = artworkService.getByArtist(artist.getArtistId());
            %>
            <div class="col-md-4">
                <div class="thumbnail">
                    <img alt="<%=artist.getFirstName() + " " + artist.getLastName()%>"
                         src="<%=artistBase+artist.getArtistId()+suffix%>">
                    <div class="caption" style="height: 600px; overflow: auto">
                        <h3 class="text-center"><%=artist.getFirstName() + " " + artist.getLastName()%></h3>
                        <p><b>Artist Link: </b><a href="<%=artist.getArtistLink()%>">
                            <%=artist.getArtistLink()!=null?artist.getArtistLink():0%>
                        </a></p>
                        <p><%=artist.getDetails()%></p>
                        <h3>Artworks: </h3>
                        <ul>
                            <%
                                for (Artwork a : artworks) {
                            %>
                            <li><a href="./artworkDetail.jsp?id=<%=a.getArtWorkId()%>">
                                <%=a.getTitle()%>
                            </a></li>
                            <%}%>
                        </ul>
                    </div>
                </div>
            </div>
            <% } %>
        </div>
        <br>
        <div class="divider"></div>
        <% } %>
    </div>
    <%@include file="footer.jsp" %>
    <!-- Bootstrap core JavaScript
        ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
